<template>
  <view class="newsDetail-page">
    <head-box></head-box>

    <view class="newsDetail-page-main tab-botton">
      <view class="_page-main-title">
        <text class="_title-text">{{ news.newsTitle }}</text>
      </view>

      <view class="_page-main-info">
        <view class="_page-main-info-chunk">
          <!-- <text class="_chunk-text">群团新闻</text> -->
          <view class="_chunk"
            ><text class="_chunk-text">发布时间：{{ news.publishTime }}</text></view
          >
          <view class="_chunk">
            <view class="_chunk-ready">
              <image class="_img" src="../../static/img/ready-icon.png" mode=""></image>
              <text class="_chunk-text">{{ newsOperateTimes.readTimes }}</text>
            </view>
          </view>
        </view>
        <view class="_page-main-info-box">
          <view class="_info-box-item"
            ><text>{{ news.newsOrg }}</text></view
          >
          <view class="_info-box-item _info-box-item-r">
            <view class="news_img" @click="onLink">
              <view class="_img">
                <image
                  v-if="mynewsOperateTimes.dzTimes == 0"
                  class="dzimg"
                  src="/static/img/dz.png"
                >
                  <image
                    v-if="mynewsOperateTimes.dzTimes > 0"
                    class="dzimg"
                    src="/static/img/dzon.png"
                  ></image> </image
              ></view>
              <text>{{ newsOperateTimes.dzTimes }}</text>
            </view>
            <view class="news_img">
              <view class="_img" @tap="onShare"
                ><image class="dzimg" src="/static/img/zf.png"></image
              ></view>
              <text style="display: none">{{ newsOperateTimes.shareTimes }}</text>
            </view>
          </view>
        </view>
      </view>

      <view class="_page-main-content">
        <u-parse :html="news.newsContent"></u-parse>
        <!-- <rich-text class="mian_body" type="text" :nodes="this.news.newsContent"></rich-text> -->
        <view class="dy-comment" v-if="0">
          <image src="/static/img/pls.png"></image><span class="text">评论</span>
        </view>
      </view>
    </view>
    <div class="hrs"></div>
    <div class="comment-dys" v-if="0">
      <p class="p1">评论 <span class="s1">1344</span></p>
    </div>
    <view class="u-border-bottom day-hr"></view>
    <div class="data-ul tab-botton">
      <div class="img" v-for="i in 10" :key="i" v-if="i===-1">
        <image src="https://img.yzcdn.cn/vant/cat.jpeg"></image>
        <div class="con">
          <p class="p1">樊先森 </p>
          <p class="p2">这个课堂的讲解可真的好啊</p>
          <p class="p3">6-18 06:24</p>
          <view class="u-border-bottom p4"></view>
        </div>
      </div>
    </div>
    <tabs-box></tabs-box>
    <!-- 分享 -->
    <pointshare :show="isShow" @close="onClose"></pointshare>
	<!-- #ifdef MP -->
	<wx-open-launch-weapp id="launch-btn" username="gh_d43f693ca31f"
	                      path="pages/newsDetail/newsDetail?id=881e6115dccb40c9b323a72c1854557a"> <!-- replace -->
	  <template>
	    <button style="width: 200px; height: 45px; text-align: center; font-size: 17px; display: block; margin: 0 auto; padding: 8px 24px; border: none; border-radius: 4px; background-color: #07c160; color:#fff;">打开小程序</button>
	  </template>
	</wx-open-launch-weapp>
	<!-- #endif -->

  </view>
</template>

<script>
  import {
    gpNewsDetail,
    gpNewsOperateTimes,
    addUserNewsOperateTimes,
    cancelUserNewsDZ,
    getUserNewsOperateTimes,
    postAppVisit,
  } from '@/common/request.js'
  import pointshare from '@/components/point-share/index'
  var graceRichText = require('../../static/richText.js')
  import {setAddUserNewsOperateTimes,getSignature,gpVisitNewsPv} from '@/api/news'

  import { share1 } from '@/mixins/share-1'
  export default {
    mixins: [share1],
    components: {
      pointshare,
    },
    data() {
      return {
        news:{}
      }
    },
    computed: {
    },
    onLoad(options) {
      var that = this
      if (options.id) {
        that.news.id = options.id
      }
      const param = { category: 1, newsId: that.news.id }
      addUserNewsOperateTimes(param).then((res) => {})
      gpNewsDetail(that.news.id).then((res) => {
        console.log('///////', res.result)
        if (res && res.result) {
          that.news = res.result
          let con = res.result.newsContent
          con = con
            .replace(/\<img/gi, '<img class="box_img"')
            .replace(/\<p/gi, '<p class="box_p"')
            .replace(/\<span/gi, '<span class="box_span"')
            .replace(/&nbsp;/g, '\xa0')
            .replace(/; width: .*?;/g, '')
          that.news.newsContent = graceRichText.format(con)
          that.shareInfo.title = res.result.newsTitle
          that.shareInfo.summary = res.result.newsTitle
          that.shareInfo.imageUrl = this.$api.getImgUrl(res.result.imageUrl)
          that.shareInfo.href = window.location.href
          gpVisitNewsPv({
            newsTitle:res.result.newsTitle,

            newsId:res.result.id
          })

        }
      })
      gpNewsOperateTimes(that.news.id).then((res) => {
        if (res && res.result) {
          that.newsOperateTimes = res.result
        }
      })
      //
      getUserNewsOperateTimes(that.news.id).then((res) => {
        if (res && res.result) {
          //that.newsOperateTimes = res.result;
          that.mynewsOperateTimes = res.result
        }
      })
    },
    onShow() {
      postAppVisit(8)

    },
    onBackPress(){
      uni.$emit('press',true)
    },
    methods: {
      //点赞
       onLink() {
       const param = { category: 2, newsId: this.news.id,}
         this.onLinks(setAddUserNewsOperateTimes,param)
      },
    },
  }
</script>

<style lang="scss" scoped>
  .newsDetail-page {
    width: 100%;
    box-sizing: border-box;
    .newsDetail-page-main {
      width: 100%;
      box-sizing: border-box;
      padding: 30rpx;
      padding-bottom: 0 !important;
      ._page-main-img {
        width: 100%;
        // height: 300rpx;
        margin-top: 30rpx;
        ._img {
          width: 100%;
          // height: 100%;
          border-radius: 10rpx;
        }
      }
      ._page-main-title {
        font-size: 38rpx;
        color: #000;
        font-weight: 600;
        line-height: 52rpx;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        ._title-text {
          display: list-item;
        }
      }
      ._page-main-info {
        margin-top: 30rpx;
        ._page-main-info-chunk {
          width: 100%;
          display: flex;
          flex-wrap: wrap;
          justify-content: space-between;
          font-size: 26rpx;
          color: #888;
          ._chunk {
            ._chunk-ready {
              display: flex;
              align-items: center;
              ._img {
                width: 40rpx;
                height: 40rpx;
                margin-right: 20rpx;
              }
            }
          }
          ._chunk-text {
          }
        }
        ._page-main-info-box {
          width: 100%;
          display: flex;
          flex-wrap: wrap;
          justify-content: space-between;
          font-size: 26rpx;
          color: #888;
          margin-top: 30rpx;
          ._info-box-item {
            width: 50%;
          }
          ._info-box-item-r {
            display: flex;
            flex-wrap: nowrap;
            justify-content: flex-end;
          }
          .news_img {
            display: flex;
            align-items: center;
            margin-left: 50rpx;

            ._img {
              width: 40rpx;
              height: 40rpx;
              margin-right: 20rpx;
            }
          }
          .dzimg {
            width: 100%;
            height: 100%;
          }
        }
      }
      ._page-main-content {
        margin-top: 30rpx;
        font-size: 32rpx;
        line-height: 60rpx;
        .dy-comment {
          display: flex;
          justify-content: flex-end;
          align-items: center;
          margin-right: 20rpx;
          image {
            width: 39rpx;
            height: 32rpx;
          }
          .text {
            color: #c5c5c5;
            font-size: 31rpx;
            padding-left: 32rpx;
          }
        }
        /deep/ .mian_body {
        }

        /deep/ .box_p {
          margin-top: 20rpx;
          font-family: 微软雅黑 !important;
          font-size: 32rpx !important;
          line-height: 60rpx !important;
          text-indent: 0 !important;
        }
        /deep/ .box_span {
          margin-top: 20rpx;
          font-family: 微软雅黑 !important;
          font-size: 32rpx !important;
          line-height: 60rpx !important;
        }
        /deep/ view {
          font-size: 32rpx;
          line-height: 60rpx;
        }

        /deep/ .box_img {
          width: 100%;
          margin: 10rpx 0;
        }
        ._rich-text {
          /deep/ img {
            width: 100%;
          }
        }
      }
    }
  }
  .hrs {
    background-color: #ededed;
    height: 17rpx;
    width: 100%;
    margin: 40rpx 0 31rpx 0;
  }
  .comment-dys {
    .p1 {
      color: #222222;
      font-size: 29rpx;
      font-weight: 900;
      padding-left: 43rpx;
      position: relative;
      display: inline;
      &:after {
        position: absolute;
        bottom: -16rpx;
        left: 50%;
        content: '';
        width: 71rpx;
        height: 7rpx;
        border-radius: 6rpx;
        background: #f79611;
      }
      .s1 {
        padding-left: 24rpx;
      }
    }
  }
  .day-hr {
    padding-top: 26rpx;
  }
  .data-ul {
    padding-top: 23rpx;
    .img {
      display: flex;
      justify-content: flex-start;
      align-content: center;
      padding-left: 15rpx;
      padding-bottom: 41rpx;
      image {
        width: 93rpx;
        height: 103rpx;
        border-radius: 50%;
      }
      .con {
        padding-left: 15rpx;
        flex: 1;
        .p1 {
          width: auto;
          font-size: 26prx;
          font-family: PingFang;
          font-weight: 500;
          color: #666666;
          line-height: 40rpx;
        }
        .p2 {
          width: auto;
          font-size: 28rpx;
          font-family: PingFang;
          font-weight: 500;
          color: #222222;
          line-height: 40rpx;
          padding: 19rpx 0 31rpx 0;
        }
        .p3 {
          width: auto;
          height: 42rpx;
          font-size: 19rpx;
          color: #999;
        }
        .p4 {
        }
      }
    }
  }
</style>
